<?php
namespace App\Lib\Storage;

use App\Wen\Utils\FileUtils;
use League\Flysystem\Config;
use League\Flysystem\FileAttributes;
use League\Flysystem\FilesystemAdapter;

/**
 * @method string publicUrl(string $path, array $config = [])
 * @method string checksum(string $path, array $config = [])
 */
class StorageHandler implements FilesystemAdapter{

    public function getUrl(string $path){
        return $path;
    }

    public function fileExists(string $path): bool
    {
        // TODO: Implement fileExists() method.
        return FileUtils::file_exists($path);
    }

    public function directoryExists(string $path): bool
    {
        // TODO: Implement directoryExists() method.
        _logger_(__file__, __line__, '-----------directoryExists-----------------');
        return true;
    }

    public function write(string $path, string $contents, Config $config): void
    {
        // TODO: Implement write() method.

    }

    public function writeStream(string $path, $contents, Config $config): void
    {
        // TODO: Implement writeStream() method.
        _logger_(__file__, __line__, '-----------writeStream-----------------');
    }

    public function read(string $path): string
    {
        // TODO: Implement read() method.
        _logger_(__file__, __line__, '-----------read-----------------');
        return '';
    }

    public function readStream(string $path)
    {
        // TODO: Implement readStream() method.
        _logger_(__file__, __line__, '-----------readStream-----------------');
    }

    public function delete(string $path): void
    {
        // TODO: Implement delete() method.
        try {
            FileUtils::force_del_url_file($path);
        }catch (\Exception $e){
            _logger_(__file__, __line__, $e->getMessage());
        }

    }

    public function deleteDirectory(string $path): void
    {
        // TODO: Implement deleteDirectory() method.
        _logger_(__file__, __line__, '-----------deleteDirectory-----------------');
    }

    public function createDirectory(string $path, Config $config): void
    {
        // TODO: Implement createDirectory() method.
        _logger_(__file__, __line__, '-----------createDirectory-----------------');
    }

    public function setVisibility(string $path, string $visibility): void
    {
        // TODO: Implement setVisibility() method.
        _logger_(__file__, __line__, '-----------setVisibility-----------------');
    }

    public function visibility(string $path): FileAttributes
    {
        // TODO: Implement visibility() method.
        _logger_(__file__, __line__, '-----------visibility-----------------');

    }

    public function mimeType(string $path): FileAttributes
    {
        // TODO: Implement mimeType() method.
        _logger_(__file__, __line__, '-----------mimeType-----------------');
    }

    public function lastModified(string $path): FileAttributes
    {
        // TODO: Implement lastModified() method.
        _logger_(__file__, __line__, '-----------lastModified-----------------');
    }

    public function fileSize(string $path): FileAttributes
    {
        // TODO: Implement fileSize() method.
        _logger_(__file__, __line__, '-----------fileSize-----------------');
    }

    public function listContents(string $path, bool $deep): iterable
    {
        // TODO: Implement listContents() method.
        _logger_(__file__, __line__, '-----------listContents-----------------');
    }

    public function move(string $source, string $destination, Config $config): void
    {
        // TODO: Implement move() method.
        _logger_(__file__, __line__, '-----------move-----------------');
    }

    public function copy(string $source, string $destination, Config $config): void
    {
        // TODO: Implement copy() method.
        _logger_(__file__, __line__, '-----------copy-----------------');
    }
}
